const { merge } = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");

const baseConfig = require("./webpack.base");
const prodConfig = {
  mode: "production",
  devtool: "cheap-module-source-map",
  plugins: [new MiniCssExtractPlugin()],
  output: {
    filename: "[name].[contenthash:8].js",
  },
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
      },
    ],
  },
  optimization: {
    minimizer: [new CssMinimizerPlugin()],
  },
};

module.exports = merge(prodConfig, baseConfig);
